#!/bin/bash

# 引用头部代码
source head.sh

echo "<h2>成绩列表</h2>"

echo "<table border=\"1\">"
echo "  <tr>"
echo "    <th>成绩号</th>"
echo "    <th>学生</th>"
echo "    <th>考试</th>"
echo "    <th>科目</th>"
echo "    <th>分数</th>"
echo "  </tr>"

idList=$($mysqlexec "select id from jx_score" | grep -v id)

for id in ${idList[@]}; do
  echo "<tr>"
  fieldList=$($mysqlexec "select jx_score.id, jx_stu.name, jx_test.name, jx_subject.name, jx_score.score from jx_score join jx_stu on jx_score.stuId=jx_stu.id join jx_test on jx_score.testId=jx_test.id join jx_subject on jx_score.subjectId=jx_subject.id where jx_score.id=$id" | grep -v id)
  for field in ${fieldList[@]}; do
    echo "<td>$field</td>"
  done
  echo "</tr>"
done
echo "</table>"
